/* File: NIDomain.m - (Interactive) Unix shell version of NIDomainPanel
 *
 * By: Christopher Lane (lane@sumex-aim.stanford.edu)
 *
 * Date: 16 July 1991
 *
 * Copyright: 1991 by The Leland Stanford Junior University.
 */

#import <stdlib.h>
#import <getopt.h>
#import <nikit/NIDomainPanel.h>
#import <appkit/Application.h>

#define USAGE "usage: %s \n"
#define EXIT_USAGE (2)

void main(int argc, char *argv[])
{
	int option, status = EXIT_SUCCESS;
	
	NXApp = [Application new];
	
	while ((option = getopt(argc, argv, "")) != EOF)
		switch (option) {
		default : status = EXIT_USAGE;
		}
	if (optind < argc) status = EXIT_USAGE;
	
	if (status == EXIT_USAGE) (void) fprintf(stderr, USAGE, [NXApp appName]);
	else {
		int flags, context = [NXApp activateSelf:YES];
		NIDomainPanel *panel = [NIDomainPanel new];
		
		if ((flags = [panel runModal]) == NX_OKTAG) (void) puts([panel domain]);
		else status = flags;
				
		[panel free];
		
		if (context) (void) [NXApp activate:context];
		}
		
	[NXApp free];
	
	exit(status);
}
